package com.atguigu01._this.exer2;

/**
 * ClassName: Bank
 * Package: com.atguigu01._this.exer2
 * Description:
 *  银行类
 * @Author ZY
 * @Create 12:51
 * @Version 1.0
 */
public class Bank {
    private Customer[] customers;//存放多个客户的数组
    private int numberOfCustomers;//记录已存储的客户个数

    public Bank(){
        customers = new Customer[10];
    }

    /**
     * 将指定姓名的客户保存在银行的客户列表中
     * @param fName
     * @param lastName
     */

    public void addCustomer(String fName,String lastName){
        Customer customer = new Customer(fName,lastName);
//        customers[numberOfCustomers] = customer;
//        numberOfCustomers++;
        //或
        customers[numberOfCustomers++] = customer;

    }

    /**
     * 获取客户列表中存储的客户的个数
     * @return
     */
    public int getNumberOfCustomers(){
        return numberOfCustomers;
    }

    /**
     * 获取指定位置上的客户
     * @param index
     * @return
     */
    public Customer getCustomer(int index){
        if(index < 0 || index >= numberOfCustomers){
            //无效范围返回空
            return null;
        }
        //有效范围
        return customers[index];
    }
}
